﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WP_GasTracker.Models;
using WP_GasTracker.Persitence;

namespace WP_GasTracker.ViewModels
{

    public class AddEditViewModel : ViewModel
    {
        private readonly IsolatedStorageGateway _storage;

        public AddEditViewModel()
        {
            Entry = new NotebookEntry {Date = DateTime.Now.Date};
            _storage = new IsolatedStorageGateway();
        }

        public NotebookEntry Entry { get; set; }

        public void Save()
        {
            _storage.StoreEntry(Entry);
        }

        public void Delete()
        {
            _storage.DeleteEntry(Entry);
        }

        public void LoadById(Guid guid)
        {
            Entry = _storage.LoadEntry(guid);
            NotifyPropertyChanged("Entry");
        }

    }
}
